package com.example.onlineeducation.ui.main


import android.os.Bundle
import android.view.View
import com.example.onlineeducation.R
import com.example.onlineeducation.base.BaseFragment
import com.example.onlineeducation.data.constant.TopicType
import com.example.onlineeducation.databinding.MainTopicFragmentBinding
import com.example.onlineeducation.ui.topic.TopicStudyFragment
import com.example.onlineeducation.viewmodel.MainTopicVM
import com.google.android.material.tabs.TabLayoutMediator
import com.gyf.immersionbar.BarHide
import com.gyf.immersionbar.ImmersionBar
import com.yc.jetpacklib.recycleView.YcViewPagerAdapter

/*
* 专题
* */
class MainTopicFragment : BaseFragment<MainTopicFragmentBinding>(MainTopicFragmentBinding::inflate) {
    private val mViewModel: MainTopicVM by ycViewModels()
    override fun initImmersionBar() {
        ImmersionBar.with(this)
            .statusBarColor(R.color.white)
            .statusBarDarkFont(true)
            .hideBar(BarHide.FLAG_SHOW_BAR)
            .fullScreen(false)
            .fitsSystemWindows(true)
            .init()
    }
    override fun MainTopicFragmentBinding.initView(view: View, savedInstanceState: Bundle?) {


        val viewPagerAdapter = YcViewPagerAdapter(
            mutableListOf(
                TopicStudyFragment(TopicType.Type.TOPIC),
                TopicStudyFragment(TopicType.Type.EXAM)
            ), requireActivity()
        )

        viewPagerTopic.adapter = viewPagerAdapter
        viewPagerTopic.isUserInputEnabled = false
        tabLayoutTopic.textDirection
        TabLayoutMediator(tabLayoutTopic, viewPagerTopic) { tab, position ->
            tab.text = mutableListOf("学习", "考试")[position]
        }.attach()


    }


}
